package org.rooster.chromosomeevaluator.rules;

import org.jgap.IChromosome;
import org.rooster.chromosomeevaluator.common.ScheduleMetrix;
import org.rooster.genetic.GenericRule;

/**
 * Created by IntelliJ IDEA.
 * User: manorama
 * Date: 6/5/12
 * Time: 9:06 PM
 * To change this template use File | Settings | File Templates.
 */
public class DuplicateEmployeeForSameSectionSameTimeSlotPenaltyRule implements GenericRule{

    private int weight = 1;

    public DuplicateEmployeeForSameSectionSameTimeSlotPenaltyRule() {
    }

    public DuplicateEmployeeForSameSectionSameTimeSlotPenaltyRule(int weight) {
        this.weight = weight;
    }

    /**
     * If same employee is set to 2 genes which represent same section and same time slot
     * this method adds a penalty for it
     * @param chromosome
     * @return  the total penalty value
     */

    @Override
    public double fitnessValueForRule(IChromosome chromosome) {
        int penalty = 1;
        penalty = ScheduleMetrix.getScheduleMetrixInstance().getNumberOfDuplicayionsInSameSection() + 1;
        return 1.0/(penalty * weight);
    }

    @Override
    public int getWeight() {
        return weight;
    }

    @Override
    public void setWeight(int value) {
        this.weight = value;
    }
}
